//处理文章分类
const db=require("../lib/db")

function classifyArticleList(classify){
    return new Promise((resolve,reject)=>{
        let sql="select * from main where classify="+classify;
        console.log(sql)
        db.querySql(sql).then(data=>{
            if(data.length==0){
                resolve(404)
            }else{
                let arr=[]
                data.map(element=>{
                    arr.push({
                        _id: Buffer.from(String(element.id)).toString("Base64"),
                        title: element.title,
                        content: element.content,
                        desc: element.desc,
                        time: element.time,
                        author: element.author,
                        authorId: element.authorId,
                        classify: element.classify,
                        __v:0
                    })
                })
                console.log(arr)
                resolve(arr)
            }
        })
    })
}

module.exports=classifyArticleList;